<template>
    <div id="box">
      <el-card class="!border-none" shadow="never">
          <el-row>
              <el-col :span="6">
                <span>数据补录日期：</span>
                <el-date-picker
                  v-model="date"
                  type="date"
                  :disabled-date="disabledDate"
                  placeholder="选择日期"
                  value-format="YYYY-MM-DD"
                />
              </el-col>
              <el-col :span="4">
                  <el-button type="primary" @click="save">保存补录</el-button>
                  <el-button type="primary" @click="submit">上报补录</el-button>
              </el-col>
          </el-row>
      </el-card>
      <el-card id="scroll-box" class="!border-none mt-4" shadow="never">
        <div class="bltitle">
          {{date}}各分厂药剂库存统计表
        </div>
        <kucun ref="stockComponent" :date="date" />
      </el-card>
    </div>
</template>
<script lang="ts" setup name="stockSubmitSupplement">
import kucun from '@/components/stock/kucun.vue';

import { GetDateStr } from '@/utils/util'
const date = ref(GetDateStr(-1))

const disabledDate = (time: Date) => {
  return time.getTime() > Date.now()  - 24 * 60 * 60 * 1000
}

// 获取子组件实例对象
const stockComponent = ref(null)
function save(){
  stockComponent.value.save()
}
function submit(){
  // 根据子组件实例对象 调用子组件的submit方法，进行提交保存
  ElMessageBox.confirm(
    '您确定要上报吗？上报后数据无法修改',
    '提示',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
  .then(() => {
    stockComponent.value.submit()
  })
}

</script>

<style>
  .el-form .el-form-item{
    margin-bottom: 0;
  }
  .bltitle{
    height: 44px;
    font-size: 20px;
    text-align: center;
    font-weight: bold;
  }
  .location{
    position: fixed;
    top:50%;
    left:230px;
  }
  .list{
    position: fixed;
    text-align: center;
    width: 200px;
    background: #eee;
    top:15%;
    left:230px;
    border-radius: 5px;
    border: 1px solid #aaa;
  }
  .item{
    margin:10px 5px;
  }
</style>